package com.cy.pj.goods.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
//@ResponseBody
//@ControllerAdvice
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(RuntimeException.class)
    //@ResponseBody
//    public String doHandleException(RuntimeException e){
//        log.error("RuntimeException.exception{}",e.getMessage());
//        return e.getMessage();
    public XResult doHandleException(RuntimeException e){
        log.error("RuntimeException.exception{}",e.getMessage());
        return new XResult(e);
    }
}
